<?php

namespace App\Http\Requests;

class SupplementSheetRequest extends FormRequest
{
    /**
     * Get the validation rules that apply to the request.
     *
     * @return array
     */
    public function rules()
    {
        $rules = [
            'match_order_id' => 'required|exists:match_orders,id',
            'type'=> 'in:withdraw,deposit'
        ];
        if($this->type == 'deposit')  {
            $rules['deposit_proof_img_url'] = ['required','mimes:jpeg,bmp,png,gif','dimensions:min_width=200,min_height=200'];
        }
        return $rules;
    }

    public function messages()
    {
        return [
            'match_order_id.required'=>['error_code'=>'F009001','message'=>'match_order 必须！'],
            'match_order_id.exists'=>['error_code'=>'F009001','message'=>'match_order 不存在！'],
            'type.in'=>['error_code'=>'F009001','message'=>'确定类型 错误！'],
            'deposit_proof_img_url.mimes'=>['error_code'=>'F009002','message'=>'发起人图片必须是 jpeg, bmp, png, gif 格式的图片！'],
            'deposit_proof_img_url.dimensions'=>['error_code'=>'F009003','message'=>'发起人图片 清晰度不够，宽和高需要 200px 以上！'],
        ];
    }
}
